import Vue from 'vue';
import VueRouter from 'vue-router';

// 解决vue-router 3.o重复点击菜单的错误
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};
Vue.use(VueRouter);

export const constantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('views/Login/Login')
  }
];

const createRouter = () =>
  new VueRouter({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  });

const router = createRouter();

export default router;
